#include <algorithm>
#include <iostream>
#include <iterator>
#include <random>
#include <vector>

#include "BarkerPair.h"

std::vector<int> generateRandomBinarySequence(int length) {
    std::random_device rd;                          // 用于生成随机种子
    std::default_random_engine rng(rd());           // 生成随机数引擎
    std::uniform_int_distribution<int> dist(0, 1);  // 均匀分布，生成0和1

    std::vector<int> sequence;
    sequence.reserve(length);

    for (int i = 0; i < length; ++i) {
        int num = dist(rng);                    // 生成随机数
        sequence.push_back(num == 0 ? -1 : 1);  // 将0映射为-1，将1映射为1
    }

    return sequence;
}

int getRandomNumber(int min, int max) {
    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_int_distribution<> dis(min, max);
    return dis(gen);
}

float getRandomFloat() {
    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_real_distribution<> dis(0.0, 1.0);
    return dis(gen);
}

int main() {
    std::cout << getRandomFloat() << std::endl;
    std::cout << getRandomNumber(0, 1);
    int length = 21;
    std::vector<int> v = generateRandomBinarySequence(length);
    for (int i = 0; i < length; ++i) {
        std::cout << v[i] << " ";
    }
    std::cout << std::endl;
}